package com.maishi.programmer.jainzhioffer;


/**
 * Created by brossdong on 2018/4/18.
 * (圆圈中最后剩下的数)
 */

public class TestProblem62 {

    public static int LastRemaining_Solution(int n, int m) {

        if (n == 0) return -1;
        int s = 0;
        for(int i = 2;i <= n;i++){
            s = (s + m) % i;
            //System.out.println(s);
        }
        return s;
    }

    public static void main(String[] args) {
        int i = LastRemaining_Solution(5, 0);
        System.out.println(i);
        System.out.println(-1 % 5);
    }

}

